package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.bean.SetmealDish;
import com.itheima.dao.SetmealDishDao;
import com.itheima.service.SetmealDishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class SetmealDishServiceImpl implements SetmealDishService {


    @Autowired
    private SetmealDishDao setmealDishDao;



    @Override
    public int insert(SetmealDish setmealDish) {
        int insert = setmealDishDao.insert(setmealDish);
        return insert;
    }

    @Override
    public List<SetmealDish> selectBySetmealId(long id) {
        LambdaQueryWrapper<SetmealDish> qw = new LambdaQueryWrapper<>();
        qw.eq(SetmealDish::getSetmealId,id);
        List<SetmealDish> setmealDishes = setmealDishDao.selectList(qw);
        return setmealDishes;


    }

    @Override
    public int deleteDishBySetmealId(long id) {
        int row = setmealDishDao.deleteById(id);
        return row;
    }


}
